package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.*;
import one.stand.response.CompanyPhotoResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 产品信息查询
 * @author Administrator
 */
@RestController
@RequestMapping("userApi/record")
@Api(description = "添加记录系列")
public class RecordController extends BaseController {

    @PostMapping("/addConsultRecord")
    @ApiOperation(value = "添加咨询(聊天)记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "员工名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "员工公司ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "sonsultType", value = "咨询类型1普通消息，2初始消息，3商品消息", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = ConsultRecordRequest.class)
    public ResultModel addConsultRecord(@RequestAttribute ConsultRecordRequest request){
        return userFegin.addConsultRecord(request);
    }

    @PostMapping("/addGoodsForwardRecord")
    @ApiOperation(value = "添加商品转发记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "入口名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "parentId", value = "上一次商品转发id", paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = GoodsForwardRecordRequest.class)
    public ResultModel<Integer> addGoodsForwardRecord(@RequestAttribute GoodsForwardRecordRequest request){
        return userFegin.addGoodsForwardRecord(request);
    }

    @ApiOperation(value = "使商品转发记录有效")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "forwardId", value = "商品转发记录id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = GoodsForwardRecordRequest.class)
    @PostMapping("validGoodsForwardRecord")
    public ResultModel<Boolean> validGoodsForwardRecord(@RequestAttribute GoodsForwardRecordRequest request) {
        return userFegin.validGoodsForwardRecord(request);
    }

    @PostMapping("/addDynamicForwardRecord")
    @ApiOperation(value = "添加文章转发记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "入口名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "dynamicId", value = "文章/动态ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = DynamicForwardRecordRequest.class)
    public ResultModel addDynamicForwardRecord(@RequestAttribute DynamicForwardRecordRequest request){
        return userFegin.addDynamicForwardRecord(request);
    }

    @PostMapping("/addCallsPhoneRecord")
    @ApiOperation(value = "添加拨打电话记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "入口名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = CallsPhoneRecordRequest.class)
    public ResultModel addCallsPhoneRecord(@RequestAttribute CallsPhoneRecordRequest request){
        return userFegin.addCallsPhoneRecord(request);
    }

    @PostMapping("/selectRoyaltyRecord")
    @ApiOperation(value = "佣金/提现列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1佣金记录，2提现记录", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = RoyaltyRecordRequest.class)
    public ResultModel<Map<String, Object>> selectRoyaltyRecord(@RequestAttribute RoyaltyRecordRequest request) {
        return userFegin.selectRoyaltyRecord(request);
    }

    @PostMapping("/doCash")
    @ApiOperation(value = "提现操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "royaltyMoney", value = "提现金额", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = RoyaltyRecordRequest.class)
    public ResultModel<Boolean> doCash(@RequestAttribute RoyaltyRecordRequest request) {
        return userFegin.doCash(request);
    }

    @PostMapping("selectCompanyPhoto")
    @ApiOperation(value = "查询企业配置图片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1公司商品展示图片，2预约商品展示图片，3动态展示图片", required =  true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = CompanyPhotoRequest.class )
    public ResultModel<List<CompanyPhotoResponse>> selectCompanyPhoto(@RequestAttribute CompanyPhotoRequest request) {
        return userFegin.selectCompanyPhoto(request);
    }
}
